home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Commun⁄Network / RevRdist Folder / Local #includes / ShowInit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-05-16  |  1.9 KB  |  99 lines  |  [TEXT/KAHL]

  1. /* -------------------  ShowInit.c   ----------------------------*/
  2. /*
  3.     Simple INIT notification routine in LightSpeedC 2.15
  4. */
  5.  
  6. #include <QuickDraw.h>
  7.  
  8. #define CKSM(i)                \
  9.     asm {                    \
  10.         ROL #1,i            \
  11.         EOR #0x1021,i        \
  12.     }
  13.  
  14. typedef struct QuickDraw {        /* QuickDraw globals */
  15.     char private[76];
  16.     long randSeed;
  17.     BitMap screenBits;
  18.     Cursor arrow;
  19.     Pattern dkGray;
  20.     Pattern ltGray;
  21.     Pattern gray;
  22.     Pattern black;
  23.     Pattern white;
  24.     GrafPtr thePort;
  25. } QuickDraw;
  26.  
  27. extern short myH : 0x92C;        /* CurApName + 28 */
  28. extern short myCheck: 0x92E;    /* CurApName + 30 */
  29. extern long oldSig: 0xA78;        /* ApplScratch */
  30. extern short oldH: 0xA7E;        /* ApplScratch + 6 */
  31.  
  32. extern void ShowINIT (short);
  33.  
  34. void ShowINIT(iconID)
  35. register short iconID;        /* ICN# resource ID */
  36. {
  37.     register Handle h;
  38.     register short i;
  39.     Rect srcRect, destRect;
  40.     BitMap myBitMap;
  41.     GrafPort myPort;
  42.     QuickDraw qdGlobals;
  43.     Ptr localA5;
  44.  
  45.     asm {
  46.         MOVE.L A5,-(SP)
  47.         LEA.L localA5,A5
  48.     }
  49.     if (!(h = GetResource('ICN#', iconID)))
  50.         goto out;    /* Error */
  51.     InitGraf(&qdGlobals.thePort);
  52.     OpenPort(&myPort);
  53.  
  54.     i = myH;
  55. //    CKSM(i);
  56.     asm {
  57.         ROL #1,i
  58.         EOR #0x1021,i
  59.     }
  60.     if (i == myCheck)
  61.         i = myH;
  62.     else
  63.         if (oldSig == 'Paul')
  64.             i = oldH;
  65.         else
  66.             i = 8;
  67.     destRect.bottom = myPort.portRect.bottom - 8;
  68.     destRect.left = myPort.portRect.left + i;
  69.     destRect.top = destRect.bottom - 32;
  70.     destRect.right = destRect.left + 32;
  71.     i += 40;
  72.     myH = i;
  73. //    CKSM(i);
  74.     asm {
  75.         ROL #1,i
  76.         EOR #0x1021,i
  77.     }
  78.     myCheck = i;
  79.  
  80.     HLock(h);
  81.     srcRect.top = srcRect.left = 0;
  82.     srcRect.bottom = srcRect.right = 32;
  83.     myBitMap.rowBytes = 4;
  84.     myBitMap.bounds = srcRect;
  85.     myBitMap.baseAddr = *h + 128;    /* Skip to mask */
  86.     CopyBits(&myBitMap, &myPort.portBits, &srcRect, &destRect, srcBic, 0L);
  87.     myBitMap.baseAddr = *h;            /* Now draw icon */
  88.     CopyBits(&myBitMap, &myPort.portBits, &srcRect, &destRect, srcOr, 0L);
  89.     HUnlock(h);
  90.     ReleaseResource(h);
  91.  
  92.     ClosePort(&myPort);
  93. out:
  94.     asm {
  95.         MOVE.L (SP)+,A5
  96.     }
  97. }
  98. /*  end of ShowInit.c */
  99.